//
//  MainViewModel.m
//  news_ios_app
//
//  Created by 陈铖 on 16/3/24.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "MainViewModel.h"
#import "NewsType.h"


@implementation MainViewModel
+ (void)getNewWithTypeId:(NSString *)typeId pageNumber:(NSInteger)pageNumber newsRusault:(NewsResault)newsResault
{
        NSMutableDictionary *parameter = [NSMutableDictionary dictionary];
        [parameter setObject:typeId forKey:@"type_id"];
        [parameter setObject:[NSString stringWithFormat:@"%ld",(long)pageNumber] forKey:@"page_number"];
        [parameter setObject:@"20" forKey:@"page_size"];
    
        [HttpRequestManager HttpRequestForArticleByTypeIdWithParameter:parameter success:^(id data) {
            if ([[data objectForKey:@"message"] isEqualToString:@"success"]) {
                NSMutableArray *newsYpyeArr = [NSMutableArray array];
                for (NSDictionary *temp in [data objectForKey:@"result"]) {
                    [newsYpyeArr addObject:[ArticleModel modelWithDictionary:temp]];
                }
                if (newsResault) {
                    newsResault(newsYpyeArr);
                }
            }else{
                NSLog(@"请求失败");
            }
        } failure:nil];
}
@end
